<template>
  <div class="nearby">
    <h3 class="nearby__title">附近店铺</h3>
    <router-link
      v-for="item in nearbyList"
      :key="item._id"
      :to="`/shop/${item._id}`"
    >
      <ShopInfo :item="item" :showBorder="true" />
    </router-link>
  </div>
</template>
<script>
import { ref } from "vue";
import { get } from "../../utils/request";
import ShopInfo from "../../components/ShopInfo";

const useNearbyList = () => {
  const nearbyList = ref([]);
  const getNeaybyList = async () => {
    const result = await get("/api/shop/hot-list");
    if (result?.errno === 0) {
      nearbyList.value = result.data;
    }
  };
  getNeaybyList();
  return { nearbyList };
};
export default {
  name: "Nearby",
  components: { ShopInfo },
  setup() {
    const { nearbyList } = useNearbyList();
    return { nearbyList };
  },
};
</script>

<style lang="scss" scoped>
@import "../../style/viriables";
.nearby {
  .nearby__title {
    margin: 0.16rem 0 0;
    font-size: 0.18rem;
    font-weight: normal;
    color: $content-fontcolor;
  }
  a {
    text-decoration: none;
  }
}
</style>
